#include <iterator>

template<class T>
class DynArray {
    T* data;
    int count;
    int capacity;
public:
    class iterator;
    friend class iterator;
    typedef std::reverse_iterator<iterator> reverse_iterator;
    class const_iterator;
    friend class const_iterator;
    typedef std::reverse_iterator<const_iterator> const_reverse_iterator;

    template<class OtherIterator>
    DynArray(OtherIterator beg, OtherIterator end) {
        // After init...
        while (beg != end)
            push_back(*beg++);
    }

    class iterator : public std::iterator<std::random_access_iterator_tag, T> {
        friend class DynArray<T>;
        DynArray<T>* p;
        int pos;
        iterator(DynArray<T>* p, bool at_end = false) {
            this->p = p;
            pos = at_end ? p->count : 0;
        }
    public:
        T& operator*() {
            return p->data[pos];
        }
        iterator& operator++() {
            if (pos < p->count)
                ++pos;
            return *this;
        }
    };
    class const_iterator : public std::iterator<std::random_access_iterator_tag, T, ptrdiff_t, const T*, const T&> {
        friend class DynArray<T>;
        const DynArray<T>* p;
        int pos;
        const_iterator(const DynArray<T>* p, bool at_end = false) {
            this->p = p;
            pos = at_end ? p->count : 0;
        }
    public:
        const T& operator*() const {
            return p->data[pos];
        }
        const_iterator& operator++() {
            if (pos < p->count)
                ++pos;
            return *this;
        }
    };
    void push_back(const T& t);
    iterator begin() {
        return iterator(this);
    }
    const_iterator begin() const {
        return const_iterator(this);
    }
    iterator end() {
        return iterator(this, true);
    }
    iterator end() {
        return iterator(this, true);
    }
    reverse_iterator rbegin() {
        return reverse_iterator(end());
    }
    reverse_iterator rend() {
        return reverse_iterator(begin());
    }
};

template<class T>
void DynArray<T>::push_back(const T& t) {
}
